package com.leyou.cart.config;

import com.leyou.common.auth.utils.RsaUtils;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.security.PublicKey;

@ConfigurationProperties(prefix = "ly.jwt")
@Data
@Slf4j
public class JwtProperties implements InitializingBean {

    private PublicKey publicKey;

    private String pubKeyPath;

    private UserTokenInfo user=new UserTokenInfo();

    @Override
    public void afterPropertiesSet() throws Exception {
        try {
            this.publicKey= RsaUtils.getPublicKey(pubKeyPath);
            log.info("【购物车】加载公钥成功");
        } catch (Exception e) {
            log.error("【购物车】加载公钥失败");
        }
    }

    @Data
    public class UserTokenInfo{

        private String cookieName;
    }

}
